package com.huawei.appmarket.service.appdetail.view.widget;

import android.content.Context;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;
import o.Logger;
import o.ContentManager;
import o.epv;
import o.eva;

public class MultiLineTextView extends TextView {
    private boolean ʼ = false;
    private e ʽ;
    private String ˊ;
    private String ˋ;
    private String ˎ;
    private int ˏ = 3;
    private float ॱ;
    private float ॱॱ;

    public interface e {
        void ˊ(boolean z);
    }

    public MultiLineTextView() {
        super(ContentManager.getInstant().getContext());
    }

    public MultiLineTextView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        float ˋ = (float) epv.ˋ(getContext(), 18);
        this.ॱॱ = ˋ;
        this.ॱ = ˋ;
    }

    public e ˊ() {
        return this.ʽ;
    }

    public void setListener(e eVar) {
        this.ʽ = eVar;
    }

    public void ˎ() {
        if (this.ˎ != null && this.ˋ != null) {
            if (this.ˎ.equals(this.ˋ)) {
                this.ˎ = this.ˊ;
            } else {
                this.ˎ = this.ˋ;
            }
            setText(this.ˎ);
        }
    }

    protected void onMeasure(int i, int i2) {
        try {
            super.onMeasure(i, i2);
            if (this.ˋ == null && this.ʼ) {
                ˋ();
                if (this.ˋ != null) {
                    super.onMeasure(i, i2);
                }
            }
        } catch (Throwable e) {
            Logger.ˋ("MultiLineTextView", "onMeasure error", e);
        }
    }

    private void ˋ() {
        int lineCount = getLineCount();
        if (lineCount != 0 || TextUtils.isEmpty(this.ˊ)) {
            int measuredWidth = getMeasuredWidth();
            if (measuredWidth > 0) {
                String str;
                boolean z = false;
                int paddingLeft = (measuredWidth - getPaddingLeft()) - getPaddingRight();
                TextPaint textPaint = new TextPaint();
                textPaint.setTextSize(getTextSize());
                if (lineCount > this.ˏ) {
                    z = true;
                    str = eva.ˊ(this.ˏ - 1, this) + ˋ(eva.ˏ(this.ˏ, this, "MultiLineTextView"), paddingLeft, textPaint);
                    if (((float) paddingLeft) < textPaint.measureText(eva.ˏ(lineCount, this, "MultiLineTextView")) + this.ॱॱ) {
                        this.ˊ += "\r\n";
                    }
                } else {
                    str = this.ˊ;
                }
                this.ˋ = str;
                this.ˎ = this.ˋ;
                if (z) {
                    setText(this.ˋ);
                }
                if (ˊ() != null) {
                    ˊ().ˊ(z);
                }
            }
        }
    }

    private String ˋ(String str, int i, TextPaint textPaint) {
        float measureText = textPaint.measureText("...") + this.ॱ;
        if (((float) i) >= textPaint.measureText(str) + measureText) {
            return eva.ˊ(str) + "...";
        }
        int i2 = 1;
        do {
            str = str.substring(0, str.length() - i2);
            i2++;
        } while (((float) i) < textPaint.measureText(str) + measureText);
        return eva.ˊ(str) + "...";
    }

    public void setOnContentChangedListener(e eVar) {
        setListener(eVar);
    }

    public String ॱ() {
        return this.ˊ;
    }

    public void setContent(String str) {
        this.ˊ = str;
        setText(str);
    }

    public String ˏ() {
        return this.ˋ;
    }

    public void setSimpleContent(String str) {
        this.ˋ = str;
        this.ˎ = str;
        setText(str);
    }

    public void setMaxLine(int i) {
        this.ˏ = i;
    }

    public void setCurContent(String str) {
        this.ˎ = str;
    }

    public void setFoldingMoreMeasureWidth(float f) {
        this.ॱ = f;
    }

    public void setFoldingShrinkMeasureWidth(float f) {
        this.ॱॱ = f;
    }

    public void setResize(boolean z) {
        this.ʼ = z;
    }
}
